/**
 * 
 */
package com.orcwar.gui.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.orcwar.R;
import com.orcwar.engine.OWGame;
import com.orcwar.gui.OWGUI;

/**
 * @author Callil
 *
 */
public class OWBottomMenuView extends LinearLayout {

	/** The game manager. */
	private OWGame game;
	
	/** GUI manager. */
	private OWGUI gui;
	
	/**
	 * @param context
	 * @param gui 
	 */
	public OWBottomMenuView(Context context) {
		super(context);
	}
	
	
	
	public OWBottomMenuView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}



	public OWBottomMenuView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}



	public void initialize(OWGUI ui) {
        game = OWGame.getInstance();
		gui = ui;
        
        Button attackButton = (Button) findViewById(R.id.button_attack);
        Button passButton = (Button) findViewById(R.id.button_pass);
        Button menuButton = (Button) findViewById(R.id.button_menu);
        
        //Handle the touch actions on the PASS button
        passButton.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_UP) {
					game.pass(gui.getController().getPlayer());
				}
				return true;
			}
		});
        
        
        //Handle the touch actions on the ATTACK button
        attackButton.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_UP) {
					gui.handleAttackButtonTap();
				}
				return true;
			}
		});
        
        
        //Handle the touch actions on the MENU button
        menuButton.setOnTouchListener(new OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_UP) {
					Toast.makeText(gui.getActivity(), "TODO", Toast.LENGTH_SHORT).show();
				}
				return true;
			}
		});
	}

}
